<template>
  <div class="basic-layout">
    <nav-header @switch-home="switchHome" />
    <component :is="currentHomeComponent" v-if="isHome" />
    <router-view v-else></router-view>
  </div>
</template>

<script setup>
import { ref, computed } from 'vue';
import { useRoute } from 'vue-router';
import NavHeader from '../components/NavHeader.vue';
import Home from '../views/HomeView.vue';
import SearchHome from '../views/SearchHome.vue';

const route = useRoute();
const currentHomeType = ref('default'); // 默认显示搜索首页

const isHome = computed(() => route.path === '/');

const currentHomeComponent = computed(() => {
  switch (currentHomeType.value) {
    case 'search':
      return SearchHome;
    case 'default':
    default:
      return Home;
  }
});

const switchHome = (type) => {
  currentHomeType.value = type;
};
</script>

<style lang="less" scoped>
.basic-layout {
  min-height: 100vh;
}
</style> 